/**
 *
 * @properties={typeid:24,uuid:"3c10bb5c-78e7-4eee-baaf-dcf8cbe7ad31"}
 */
function Alta()
{
	controller.newRecord()
	//userv_id = globals.gUservId
}

/**
 *
 * @properties={typeid:24,uuid:"4b2b37a7-419e-4ddb-98bb-95ba4ba96963"}
 */
function altaDetalle()
{
	tab_cabecera_to_tablas_detalle.newRecord()
	//tab_cabecera_to_tablas_detalle.userv_id = globals.gUservId 
}

/**
 *
 * @properties={typeid:24,uuid:"54e729e7-5571-4e72-a143-457aceccb473"}
 */
function Baja()
{
	//TODO función anulada - es muy peligrosa
	//var resp = plugins.dialogs.showQuestionDialog( 'Confirma',  '¿Seguro que desea dar de baja? Primero, asegurese de dar de baja los registros asociados',  'Si', 'No')
	//if (resp == 'Si')
	//	currentcontroller.deleteRecord()
}

/**
 * @properties={typeid:24,uuid:"2BC7272D-9089-4C6F-BDD1-870788DC0CCB"}
 */
function chequeaBloqueo() {
	//var bloqueo = bloqueado
	//elements.btn_alta_cab.enabled = !bloqueado
	//elements.btn_baja_cab.enabled = !bloqueado
	elements.btn_modif_cab.enabled = !bloqueado
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"388F1316-618A-4C29-B870-C5E11BFAB6A5"}
 */
function onShow(firstShow, event) {
	databaseManager.setAutoSave(true)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"5446B267-0F60-4F9D-BD6E-6A3486E7E6CE"}
 */
function bajaDtl(event) {
	var resp = globals.DIALOGS.showQuestionDialog( 'Confirma',  '¿Seguro que desea dar de baja? Primero, asegurese de dar de baja los registros asociados',  'Si', 'No')
	if (resp == 'Si')
		tab_cabecera_to_tablas_detalle.deleteRecord()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"831DB2CB-F925-4027-8DD7-B934C7111EBB"}
 */
function modificar(event) {
	if (bloqueado == 0)
	{
		controller.readOnly = 0
		elements.btn_alta_dtl.enabled = 1
		elements.btn_baja_dtl.enabled = 1
	}
	else
	{
		globals.DIALOGS.showInfoDialog("Tabla bloqueada","El acceso a la tabla está bloqueado","Ok")	
	}
}

/**
 * Handle record selected.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"E540977B-D032-4B17-8999-EFC0BC2760D7"}
 */
function onRecordSelection(event) {
	controller.readOnly = 1
	elements.btn_alta_dtl.enabled = 0
	elements.btn_baja_dtl.enabled = 0
	chequeaBloqueo()
}
